

use "Data/Census w-restrictions.dta", clear

drop if (year == 2010 & fyend <= 630) | (year == 2011 & fyend > 630)

gen log_capital = log(total_capital_outlays)
gen log_interest = log(total_interest_on_debt)
gen log_tdo = log(total_debt_outstanding + 1)
gen log_expend = log(total_expenditure + 1)
gen log_rev_own = log(total_rev_own_sources + 1)
gen log_tax = log(total_taxes)
gen log_op = log(total_current_oper + 1)

foreach var in log_interest {
gen l_`var' = l.`var'
gen l2_`var' = l2.`var'
gen f_`var' = f.`var'
gen f2_`var' = f2.`var'
gen f5_`var' = f5.`var'
}

tab year, gen(y)

gen ltd2 = ltd_iss_all_other * ltd_iss_all_other
gen Qdummy = ltd_iss_all_other <= 10000
gen ltd_Q = ltd_iss_all_other * Qdummy
gen ltd_Q2 = ltd2 * Qdummy
rename ltd_iss_all_other ltd

drop if ltd > 30000 | ltd < 5000

drop if ltd >= 9500 & ltd <= 12000

* Columns 1-3
xtreg f_log_interest Qdummy ltd ltd_Q y2-y18, fe cluster(id)
outreg2 using "Table 5", keep(Qdummy) dec(3) nocons nor2 replace
xtreg f_log_interest Qdummy ltd ltd_Q y2-y18 log_rev_own log_expend, fe cluster(id)
outreg2 using "Table 5", keep(Qdummy) dec(3) nocons nor2 append
xtreg f_log_interest Qdummy ltd ltd2 ltd_Q ltd_Q2 y2-y18 log_rev_own log_expend, fe cluster(id)
outreg2 using "Table 5", keep(Qdummy) dec(3) nocons nor2 append


* Calculations - Section 6.3
xtreg f_log_interest Qdummy ltd ltd_Q y2-y18 if type_code == 1 | type_code == 2 | type_code == 3, fe cluster(id)
xtreg f_log_interest Qdummy ltd ltd_Q y2-y18 if type_code == 4 | type_code == 5, fe cluster(id)


* Columns 4-6
drop if ltd >= 9000 & ltd <= 14500

xtreg f_log_interest Qdummy ltd ltd_Q y2-y18, fe cluster(id)
outreg2 using "Table 5", keep(Qdummy) dec(3) nocons nor2 append
xtreg f_log_interest Qdummy ltd ltd_Q y2-y18 log_rev_own log_expend, fe cluster(id)
outreg2 using "Table 5", keep(Qdummy) dec(3) nocons nor2 append
xtreg f_log_interest Qdummy ltd ltd2 ltd_Q ltd_Q2 y2-y18 log_rev_own log_expend, fe cluster(id)
outreg2 using "Table 5", keep(Qdummy) dec(3) nocons nor2 append
